package com.pfsoft.myspringbootstarter.configuration;

import com.pfsoft.myspringbootstarter.properties.PersonProperties;
import com.pfsoft.myspringbootstarter.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author pengfei
 * @date 2022年07月19日 14:07
 */

@EnableConfigurationProperties(PersonProperties.class)
@Configuration
public class PersonInitConfig {

    @Autowired
    private PersonProperties personProperties;

    @Bean
    public PersonService personService(){
        return  new PersonService(personProperties.getName(), personProperties.getAge());
    }
}
